<?php 
      echo $this->Html->css("chosen");
      echo $this->Html->css("dataTables");
      echo $this->Html->css("validationEngine.jquery");
 ?>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/customInput.jquery.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/chosen.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/layout_table.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/manager_news_types.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.validationEngine.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.validationEngine-vi.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.autotab.js"></script>

<div class="titlePage">
<h1>Quản lý loại bài viết</h1>
</div>
<div class="onecolumn">
	<div class="header">
		<span><span class="ico gray shopping_basket"></span>Loại bài viết</span>
	</div>
	<div class=" clear"></div>
	<div class="content">
             	<form id="validation">
							<div class="tableName">
								<table class="display data_table2 listNewsTypes" >
									<thead>
										<tr>
											<th><div class="th_wrapp">Mã loại</div></th>
											<th><div class="th_wrapp">Tên loại</div></th>
											<th><div class="th_wrapp">Tên thay thế</div></th>
											<th><div class="th_wrapp">Thuộc loại bài viết</div></th>
											<th><div class="th_wrapp">Quản lý</div></th>
										</tr>
									</thead>
									<tbody>
									<?php 
				foreach ($news_types as $item) {
			?>
					<tr class="odd gradeX editNT" id="<?php echo $item['t']['id'].'_edit'?>">
      					<td><?php  echo $item['t']['id']; ?></td>
      					<td class='editName'><div class='old_name'><?php  echo $item['t']['name'];?></div>
      						<input id="<?php echo $item['t']['id'].'_edit_n'?>" value ="<?php echo $item['t']['name'];?>" class='validate[required,min[1]] tmp_name' style="display: none"/>
      					</td>
      					<td class='editAlias'><div class='old_alias'><?php  echo $item['t']['alias'];?></div>
      						<input id="<?php echo $item['t']['id'].'_edit_a'?>" value ="<?php echo $item['t']['alias'];?>" class='validate[required,min[1]] tmp_alias' style="display: none"/>
      					</td>
      					<td class='editParent'><div class='old_parent'><?php  echo $item['t1']['name'];?></div>
      						<select id="<?php echo $item['t']['id'].'_edit_p'?>" data-placeholder="Chọn loại bài viết..." class="chzn-select tmp_parent" tabindex="2" style="display: none">
		                          <option value=""></option> 
		                          <?php foreach ($news_types_parent as $item1)
		                          		if ($item1['t']['id'] == $item['t1']['id'])
											echo "<option selected='selected' value='".$item1['t']['id']."'>".$item1['t']['name']."</option>";
										else 
											echo "<option value='".$item1['t']['id']."'>".$item1['t']['name']."</option>";?>
		                     </select>
      					</td>
      			
	      					<td >
                                <span class='btnEdit'>
                                      <a  title="Edit" class='btnEdit' >
                                           <img src="<?php echo $this->webroot; ?>img/icon/color_18/pencil.png" >
                                      </a>
                                 </span> 
                                 <span class="tip" >
                                       <a title="Delete"  class="btnDelete" id="<?php echo $item['t']['id']?>">
                                           <img src="<?php echo $this->webroot; ?>img/icon/color_18/delete.png" >
                                       </a>
                                </span> 
                                <span class='btnSave' style="display: none">
                                      <a  title="Save" >
                                           <img src="<?php echo $this->webroot; ?>img/icon/color_18/checkmark2.png" >
                                      </a>
                                 </span>
                                 <span class='btnCancel' style="display: none">
                                      <a  title="Cancel" >
                                           <img src="<?php echo $this->webroot; ?>img/icon/color_18/cross.png" >
					                                      </a>
					                                 </span>
					                            </td>
      										</tr><?php }?>
					</tbody>
				</table>
            </div>
		</form>
		<div id="alert_product"></div>
		<form id="validation">
			<a class="uibutton icon add addNewNewsType">Thêm mới</a>
			<div class="newNewsType">
				<h4>Loại bài viết mới</h4>
				<div class="section">
					<label>
					Tên loại bài viết:
					
					</label>
					<div>
						<input class="validate[required] large" type="text" id="news_type_name">
						
					</div>
				</div>
				<div class="section">
					<label>
					Tên thay thế:
					
					</label>
					<div>
						<input class="validate[required] large" type="text" id="news_type_alias">
						
					</div>
				</div>
				<div class="section">
					<label>
					Thuộc thể loại bài viết:
					</label>
					<div id="search_news_type">
						 <select data-placeholder="Chọn loại bài viết..." class="chzn-select choose_news_type" tabindex="2" >
	                          <option value=""></option> 
	                          <?php foreach ($news_types_parent as $item) {?>
								<option value="<?php echo $item['t']['id']; ?>"><?php echo $item['t']['name'];}?></option>
	                     </select>					
					</div>
				</div>
				<div class="buttonNewNewsType">
					<a class="uibutton add_news_type"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
		</form>
	</div>
</div>